<?php

class dbBase 
{
	private static $instance = null;
	private $_handle = null;
	
	/**
	 * 连接数据库
	 *
	 * 私有的构造函数
	 */
	private function __construct() {
		try {
			$this->_handle = new PDO("mysql:host=".config::DBHOST.";dbname=".config::DBNAME ,config::DBUSER ,config::DBPASS);
		} catch (PDOException $e) {
			throw new Exception('connection database failed'.$e->getMessage());
		}
		$this->_handle->query("set names utf8");
	}
	/**
	 * 
	 *
	 * @return self::$instance;
	 */
	public static function getInstance() {
		if(self::$instance === null) {
			self::$instance = new dbBase();
		}
		return self::$instance;
	}

	public function get() {
		return $this->_handle;
	}
}

?>